﻿/**
 * ...
 * @author George Mavchun
 */

package gui.hug;

import flash.display.SimpleButton;
import flash.text.TextFormat;
import gui.hug.priv.HUGButtonDisplayState;

class HUGButton extends SimpleButton
{
	// button colors
	private var dColor : Int;
	private var oColor : Int;
	private var uColor : Int;
	private var hColor : Int;
	
	// text sizes
	private var dTextSize: Int;
	private var oTextSize : Int;
	private var uTextSize : Int;
	private var hTextSize: Int;
	
	// text colors
	private var dTextColor : Int;
	private var oTextColor : Int;
	private var uTextColor : Int;
	private var hTextColor : Int;
	
	// text faces
	private var dTextFace : String;
	private var oTextFace : String;
	private var uTextFace : String;
	private var hTextFace : String;
	
	public function new(text : String) 
	{
		super();
		// default button colors
		this.dColor = HUGColors.VK_BUTTON;
		this.oColor = HUGColors.VK_BUTTON;
		this.uColor = HUGColors.VK_BUTTON;
		this.hColor = HUGColors.VK_BUTTON;
		
		// default text sizes
		this.dTextSize = 11;
		this.oTextSize = 11;
		this.uTextSize = 11;
		this.hTextSize = 11;
		
		// default text colors
		this.dTextColor = HUGColors.WHITE;
		this.oTextColor = HUGColors.VK_DELIMETER_LINE;
		this.uTextColor = HUGColors.WHITE;
		this.hTextColor = HUGColors.WHITE;
		
		// default text faces
		this.dTextFace = "Verdana";
		this.oTextFace = "Verdana";
		this.uTextFace = "Verdana";
		this.hTextFace = "Verdana";
		
		refreshStates(text);
		
		this.enabled = true;
		this.useHandCursor = true;
	}
	
	private function refreshStates(text : String) {
		downState = new HUGButtonDisplayState(text, new TextFormat(dTextFace, dTextSize, dTextColor), dColor);
		overState = new HUGButtonDisplayState(text, new TextFormat(oTextFace, oTextSize, oTextColor), oColor);
		upState = new HUGButtonDisplayState(text, new TextFormat(uTextFace, uTextSize, uTextColor), uColor);
		hitTestState = new HUGButtonDisplayState(text, new TextFormat(hTextFace, hTextSize, hTextColor), hColor);
	}
	
	public function setLocation(left : Float, top : Float) {
		this.x = left;
		this.y = top;
	}
	public function setSize(width :Int, height : Int) {
		this.height = height;
		this.width = width;
	}
	public function setDownStateColor(color : Int) {
		this.dColor = color;
	}
	
	public function setOverStateColor(color : Int) {
		this.oColor = color;
	}
	
	public function setUpStateColor(color : Int) {
		this.uColor = color;
	}
	
	public function setHitTestStateColor(color : Int) {
		this.hColor = color;
	}
	
	public function setText(str : String) {
		refreshStates(str);
	}
}